package com.mitgroup.dmrvs.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.mitgroup.dmrvs.R;
import com.mitgroup.dmrvs.utils.AppManager;
import com.mitgroup.dmrvs.utils.Utils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.trinea.android.common.util.PreferencesUtils;

public class SettingsActivity extends AppCompatActivity {
    private Intent intent;
    @BindView(R.id.btn_back)
    public Button back;
    @OnClick(R.id.btn_back)
    public void onBack(View view) {
        this.finish();
    }
    @BindView(R.id.tv_user_name)
    public TextView tvUserName;
    @BindView(R.id.iv_quit)
    public Button quit;
    @OnClick(R.id.iv_quit)
    public void onQuit(View view) {
        Utils.Exit(this);
    }

    @BindView(R.id.btn_nav01)
    public Button btnReceiveCar;
    @OnClick(R.id.btn_nav01)
    public void onReceiveCar(View view) {
        intent = new Intent(SettingsActivity.this,
                ReceiveCarActivity.class);
        startActivity(intent);
    }
    @BindView(R.id.btn_nav02)
    public Button btnDiagnose;
    @OnClick(R.id.btn_nav02)
    public void onDiagnose(View view) {
        intent = new Intent(SettingsActivity.this,
                CarDiagnoseActivity.class);
        startActivity(intent);
    }
    @BindView(R.id.btn_nav03)
    public Button btnSettings;

    @BindView(R.id.btn_operator_manager)
    public Button btnOperatorManager;
    @OnClick(R.id.btn_operator_manager)
    public void onOperatorManager(View view) {
        intent = new Intent(SettingsActivity.this,
                OperatorManageActivity.class);
        startActivity(intent);
    }
    @BindView(R.id.btn_maintenance_item_manager)
    public Button btnMaintenanceItemManager;
    @OnClick(R.id.btn_maintenance_item_manager)
    public void onMaintenanceItemManager(View view) {
        intent = new Intent(SettingsActivity.this,
                MaintenanceItemManagerActivity.class);
        startActivity(intent);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);
        ButterKnife.bind(this);
        initView();
    }
    private void initView() {
        AppManager.getAppManager().addActivity(this);
        String userId = PreferencesUtils.getString(SettingsActivity.this, "userId");
        String userType = PreferencesUtils.getString(SettingsActivity.this, "userType");
        if ("1".equals(userType)) {
            btnOperatorManager.setVisibility(View.GONE);
        }
        String userName = PreferencesUtils.getString(SettingsActivity.this, "userName");
        tvUserName.setText(userName);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        AppManager.getAppManager().finishActivity(this);
    }
}
